<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>员工信息</title>
    <link rel="stylesheet" href="/pc/layui/css/layui.css" media="all" />
</head>
<body>
     {{csrf_field()}}
    <blockquote class="layui-elem-quote news_search" style="margin-top:1.2em;">
     <div class="layui-inline" style="width: 70px;height: 70px;background: #2fa89d;border-radius: 50%"><img src="/staff/account/img/yg.png" style="width: 50px;margin-top: 5px;margin-left:10px;"></div>
     <div class="layui-inline">
      <a class="layui-btn linksAdd_btn" style="background-color:#1aa094;"> <img src="/staff/storage/img/tj2.png" style="margin-right: 10px;height: 36px;margin-bottom: 2px;">添加员工</a>
     </div>
    </blockquote>
@if(!empty($areaArr))
    <div class="layui-collapse" lay-accordion="">
        @foreach($areaArr as $vel)
        <div class="layui-colla-item">
            <h2 class="layui-colla-title"  style="background: #1aa094;">{{$vel['name']}}</h2>
            @if(!empty($vel['staffArr']))
                <div class="layui-colla-content">
                    <div class="layui-collapse" lay-accordion="">
                        @foreach($vel['staffArr'] as $v)
                        <div class="layui-colla-item" id="account_{{$v['id']}}">
                            <h2 class="layui-colla-title"  style="background: #3cbf8a;">{{$v['name']}}</h2>
                            <div class="layui-colla-content">
                                <p style="color: #1aa094;">手机号：<span style="color:red">{{$v['phone']}}</span>&nbsp;&nbsp;&nbsp;&nbsp;<br>
                                    邮箱：<span style="color:red">{{$v['email']}}</span>&nbsp;&nbsp;&nbsp;&nbsp;<br>
                                    角色：@if($v['staff_role_id'] == 3) <span style="color:red">管理员</span> @else <span style="color:red">员工</span> @endif<br>
                                <a class="layui-btn layui-btn-mini links_edit" area="{{$vel['area_id']}}" account="{{$v['id']}}"><img src="/staff/storage/img/bj.png" style="margin-bottom: 1px"> 编辑</a>
                                <a class="layui-btn layui-btn-danger layui-btn-mini links_del" data-id="1" onclick="delAccount({{$v['id']}})"><i class="layui-icon"></i> 删除</a>
                                </p>
                            </div>
                        </div>
                        @endforeach
                    </div>
                </div>
            @endif
        </div>
        @endforeach
    </div>
@endif
<script type="text/javascript" src="/staff/layout/js/jquery.min.js"></script>
<script type="text/javascript" src="/pc/layui/layui.js"></script>
<script type="text/javascript" src="/staff/account/js/account.js"></script>
<script>
    layui.use(['element', 'layer'], function(){
        var element = layui.element();
        var layer = layui.layer;

        //监听折叠
        element.on('collapse(test)', function(data){
            layer.msg('展开状态：'+ data.show);
        });
    });
    function delAccount(id){  //删除
        layer.confirm('确定删除此信息？',{icon:3, title:'提示信息'},function(index){
            $.ajax({
                url:'/staff/account/destroy',
                type:'post',
                async:false,
                data:{
                    "_token": $("input[name=_token]").val(),
                    'id':id
                },
                dataType:'json',
                success:function (data) {
                    if(data.status == 1){
                        $('#account_'+id).remove();
                        layer.msg('删除成功！',{time:800});
                        layer.close(index);
                        // parent.location.reload();
                    }else{
                        layer.msg('删除失败！',{time:800});
                        layer.close(index);
                    }
                }

            })
            layer.close(index);
        });
    }
</script>
</body>
</html>
